<?php

namespace App\Listeners;

use App\Common\Constant\Params;
use App\Events\MasterAssureFund;
use App\Events\MasterOrderRefund;
use App\Events\OrderRefund;
use App\Events\Tested;
use App\Models\MasterFund;
use App\Models\MasterTradeLog;
use App\Models\Order;
use App\Services\ISystemService;
use Illuminate\Cache\Events\CacheHit;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Log;

class TestedListener implements ShouldQueue
{

    use InteractsWithQueue;

    public $tries = 3;

    public $timeout = 30;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  CacheHit  $event
     * @return void
     */
    public function handle(Tested $event)
    {
        $order = Order::find($event->order_id);
        if(!$order){
            throw new \Exception('miss order');
        }
        Log::debug('test api: '.$order->toJson());
    }

    public function failed(Tested $event, \Exception $exception)
    {
        //
    }
}
